<?php
class marketitemdao extends CI_Model{
	function __construct()
	{
		// Call the Model constructor
		parent::__construct();
	}

	public function getbyid($id){
		$this->db->select('*');
		$this->db->from('market_item');
		$this->db->where('market_item_id',$id);
		$query = $this->db->get();
		$market_item = $query->row();
		return $market_item;
	}
	
	public function get_all(){
		$this->db->select('*');
		$this->db->from('market_item');
		$query = $this->db->get();
		$market_items = $query->result();
		return $market_items;
	}
	
	public function insert($market_item_id,$market_id,$item_id,$item_cost,$market_item_thumbnail_url){
		$data = array(
				'market_item_id' => $market_item_id,
				'market_id' => $market_id,
				'item_id' => $item_id,
				'item_cost' => $item_cost,
				'market_item_thumbnail_url' => $market_item_thumbnail_url
		);
		$str = $this->db->insert_string('market_item', $data);
		$res = $this->db->query($str);
		return $res;
	}
	
	public function del($market_item_id) {
		if (intval($market_item_id) > 0) {
			$this->db->where('market_item_id',$market_item_id);
			$this->db->delete('market_item');
			return ($this->db->affected_rows() == 1) ? TRUE : FALSE;
		}
		return false;
	}
}
?>